﻿namespace Notification
{
    public class FileHelper
    {
        public static string TranslateFileSize(long fileLength)
        {
            var result = "";
            if (fileLength < 1024)
            {
                result = fileLength + "B";
            }
            else if (fileLength >= 1024 && fileLength < 1024*1024)
            {
                result = (fileLength/1024.0).ToString("F2") + "KB";
            }
            else if (fileLength >= 1024*1024 && fileLength < 1024*1024*1024)
            {
                result = (fileLength/1024.0/1024).ToString("F2") + "MB";
            }
            else
            {
                result = (fileLength/1024.0/1024/1024).ToString("F2") + "GB";
            }
            return result;
        }
    }
}